/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package org.sbbs.demo.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Types;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.Length;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.JavaType;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.annotations.Nationalized;
import org.hibernate.annotations.Type;
import org.hibernate.type.descriptor.java.CharacterArrayJavaType;
import org.sbbs.base.jpa.entity.BaseEntity;
import org.sbbs.demo.entity.enumtype.Gender;
import org.sbbs.demo.entity.enumtype.GenderConverter;
import org.sbbs.demo.entity.enumtype.GenderType;
import org.sbbs.demo.entity.enumtype.PhoneType;

/**
 *
 * @author jenkins
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "basic_value_entity")
@Comment("样例表")
public class BasicValueBean extends BaseEntity {

    @Comment("姓名")
    private String name;
    @Column(name = "phone_number", nullable = true)
    @Comment("电话号码")
    private String number;

    @Enumerated(EnumType.ORDINAL)
    @Column(name = "phone_type_ordianl", nullable = true)
    @Comment("电话类型:序号型")
    private PhoneType typeOrdianl;

    @Enumerated(EnumType.STRING)
    @Column(name = "phone_type_string", nullable = true)
    @Comment("电话类型:字符串")
    private PhoneType typeString;

    @Convert(converter = GenderConverter.class)
    @Column(name = "gender", nullable = true)
    @Comment("性别:属性转换器")
    public Gender gender;

    @Type(GenderType.class)
    @Column(length = 6, name = "gender_type", nullable = true)
    @Comment("性别:用户自定义")
    public Gender genderType;

    @Column(name = "implicit", nullable = true)
    @Comment("布尔型:简单")
    boolean implicit;
    // this will get mapped to CHAR or NCHAR with a conversion
    @Convert(converter = org.hibernate.type.YesNoConverter.class)
    @Column(name = "convertedYesNo", nullable = true)
    @Comment("布尔型:YN转换")
    boolean convertedYesNo;

// this will get mapped to CHAR or NCHAR with a conversion
    @Convert(converter = org.hibernate.type.TrueFalseConverter.class)
    @Column(name = "convertedTrueFalse", nullable = true)
    @Comment("布尔型:TF转换")
    boolean convertedTrueFalse;

// this will get mapped to TINYINT with a conversion
    @Convert(converter = org.hibernate.type.NumericBooleanConverter.class)
    @Column(name = "convertedNumeric", nullable = true)
    @Comment("布尔型:01数字转换")
    boolean convertedNumeric;

    // these will both be mapped using TINYINT
    @Column(nullable = true)
    @Comment("byte包装")
    Byte byteWrapper;
    @Comment("byte基础")
    @Column(nullable = true)
    byte bytePrimitive;

// these will both be mapped using SMALLINT
    @Comment("short包装")
    @Column(nullable = true)
    Short shortwrapper;
    @Comment("short基础")
    @Column(nullable = true)
    short shortPrimitive;

// these will both be mapped using INTEGER
    @Comment("int包装")
    @Column(nullable = true)
    Integer intWrapper;
    @Comment("int基础")
    @Column(nullable = true)
    int intPrimitive;

// these will both be mapped using BIGINT
    @Comment("long包装")
    @Column(nullable = true)
    Long longwrapper;
    @Comment("long基础")
    @Column(nullable = true)
    long longPrimitive;

// will be mapped using NUMERIC
    @Comment("bigint包装")
    @Column(nullable = true)
    BigInteger bigIntWrapper;

// these will be mapped using DOUBLE, FLOAT, REAL or NUMERIC
// depending on the capabilities of the database
    @Comment("double包装")
    @Column(nullable = true)
    Double doubleWrapper;
    @Comment("double基础")
    @Column(nullable = true)
    double doublePrimitive;

// these will be mapped using FLOAT, REAL or NUMERIC
// depending on the capabilities of the database
    @Comment("float包装")
    @Column(nullable = true)
    Float floatWrapper;
    @Comment("float基础")
    @Column(nullable = true)
    float floatPrimitive;

// will be mapped using NUMERIC
    @Comment("bigdec包装")
    @Column(nullable = true)
    BigDecimal bigDecWrapper;
//
//    // these will be mapped using CHAR
//    @Comment("char包装")
//    @Column(nullable = true)
//    Character charWrapper;
//    @Comment("char基础")
//    @Column(nullable = true)
//    char charPrimitive;
//
//    // will be mapped using VARCHAR
//    @Comment("字符串")
//    @Column(nullable = true)
//    String string;
//
//// will be mapped using CLOB
//    @Lob
//    @Comment("字符串clob")
//    @Column(nullable = true)
//    String stringClob;
////下面两个之一效果相同
//    @Column(length = Length.LONG)
//    @Comment("字符串LONGVARCHAR")
//    @JdbcTypeCode(Types.LONGVARCHAR)
//    private String text;
//
//    // will be mapped using NVARCHAR
//    @Nationalized
//    @Comment("字符串国际化")
//    String nstring;
//
//// will be mapped using NCLOB
////    @Lob
////    @Nationalized
////    @Comment("字符串国际化nclob")
////    String nclobString;
//    // mapped as VARCHAR
//    @Comment("字符数组:基础")
//    @Column(nullable = true)
//    char[] charArrayPrimitive;
//    
//    @Comment("字符数组:包装")
//    @Column(nullable = true)
//    Character[] charArrayWrapper;
//    
//    @Comment("字符数组:老方法")
//    @Column(nullable = true)
//    @JavaType(CharacterArrayJavaType.class)
//    Character[] charArrayWrapperOld;

// mapped as CLOB
//    @Lob
//    @Comment("字符数组:基础clob")
//    @Column(nullable = true)
//    char[] charArrayPrimitiveClob;
//    @Lob
//    @Comment("字符数组:包装clob")
//    @Column(nullable = true)
//    Character[] charArrayWrapperClob;
}
